package com.imy.lua.helper;

import android.content.res.Configuration;

import com.immomo.mls.annotation.LuaBridge;
import com.imy.common.util.UiUtil;
import com.imy.lua.LuaCore;
import com.imy.lua.helper.opencv.ImageFindHelper;
import com.imy.lua.helper.properties.PropertiesLoaderHelper;

public class PointScaleHelper {
    private static volatile PointScaleHelper gCore = new PointScaleHelper();
    private int widthMetrics;
    private int heightMetrics;
    private int screenWidth;
    private int screenHeight;

    public static PointScaleHelper get() {
        return gCore;
    }

    private PointScaleHelper() {
        screenHeight = UiUtil.getDeviceHeight(LuaCore.get().getContext());
        screenWidth = UiUtil.getDeviceWidth(LuaCore.get().getContext());
        widthMetrics =  PropertiesLoaderHelper.getScriptWidth();
        heightMetrics = PropertiesLoaderHelper.getScriptHeight();
    }


    public int getWidthMetrics() {
        return widthMetrics;
    }

    public int getHeightMetrics() {
        return heightMetrics;
    }

    public int changeX(int x) {
        float p = screenWidth * 1.0f / widthMetrics * 1.0f;
        return (int) (x * p);
    }

    public int changY(int y) {
        float p = screenHeight * 1.0f / heightMetrics * 1.0f;
        return (int) (y * p);
    }




}
